Skip to content

feat: settlements + financials + admin tokens; fix CSV export (#22) and abort exit code (#24) - #33

Open
LucasLeguizamo wants to merge 2 commits into
mainfrom
feat/issues-22-24-settlements
Open

feat: settlements + financials + admin tokens; fix CSV export (#22) and abort exit code (#24)#33
LucasLeguizamo wants to merge 2 commits into
mainfrom
feat/issues-22-24-settlements

Conversation

@LucasLeguizamo

Copy link
Copy Markdown
Contributor

Sincroniza el CLI con el contrato B2B 1.5.0 y admin 1.1.0, y arregla dos bugs reportados.

Fixes

  • ft reports export reconciliation: CSV output has literal \n instead of real newlines #22 — CSV con \n literal. GET /reports/exports/reconciliation responde text/csv, así que el payload llega como string. Pasaba por print()/JSON.stringify, que encomillaba el archivo entero y escapaba los saltos como los dos caracteres \ + n. Ahora los payloads string se escriben verbatim. Verificado con od -c contra la API real: arranca en sale_reference,… sin comilla inicial y con 0x0A reales.
  • delete abortado (sin TTY / confirmación rechazada) sale con exit code 0 #24 — abort con exit 0. Los cuatro sitios de confirmación (delete, api-keys revoke, admin … suspend, event-dates delete) pasan por confirmOrExit: rechazo → exit 1; sin TTY y sin --yes → falla de inmediato apuntando a --yes, en vez de imprimir Aborted. y seguir.

Contrato 1.5.0 / admin 1.1.0

Además: --csv real en todos los reports export y --json en ft login / ft config (commit que había quedado sin mergear).

Verificación

pnpm typecheck · pnpm lint · pnpm test (19 tests, 2 archivos nuevos: passthrough de CSV string y exit code del abort) · smoke test en vivo de settlements list, reports financials y el export de conciliación.

Closes #22, closes #24. Avanza #32 (queda pendiente el PDF).

🤖 Generated with Claude Code

LucasLeguizamo and others added 2 commits August 3, 2026 15:37
Exports promised "(CSV)" in help but only emitted JSON; wire toCsv into
buyers/attendees/subscribers/reconciliation. Add --json to `ft login` and
`ft config` and move the login confirmation to stderr so `| jq` stays clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… exit code

Sync to B2B contract 1.5.0 + admin 1.1.0 and wire the endpoints that unblock
the finance integration:

- `ft settlements list`   → GET /settlements (issue #32)
- `ft reports financials` → GET /reports/financials (issue #32)
- `ft admin tokens …`     → GET/POST/DELETE /tokens (admin 1.1.0)
- `ft events list --q`    → new query param in 1.5.0

Fixes:
- #22 `reports export reconciliation` answers text/csv, so the payload arrives
  as a string. Running it through print()/JSON.stringify quoted the whole file
  and escaped newlines as a literal backslash-n, making the CSV unparseable.
  String payloads are now written verbatim.
- #24 aborting a destructive command exited 0, so `ft … delete && next-step`
  ran next-step. All four confirmation sites now go through confirmOrExit,
  which exits 1 on refusal and fails fast (pointing at --yes) with no TTY.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add settlements, financials & admin PAT; fix CSV export and abort exit code

🐞 Bug fix ✨ Enhancement 🕐 20-40 Minutes

Grey Divider

AI Description

• Fixes #22: string CSV payloads are written verbatim (no JSON quoting/escaped newlines).
• Fixes #24: destructive command aborts now exit 1 and fail fast without a TTY.
• Adds settlements, financials, admin PAT tokens, and event search to match contract updates.
Diagram

graph TD
  CLI["CLI Commands"] --> Confirm["confirmOrExit()"] --> Exit["process.exit(1)"]
  CLI --> Export["printExport()"] --> CSV["CSV / text passthrough"]
  CLI --> SDK["Generated SDK"] --> B2BAPI[("B2B API v1.5.0")]
  SDK --> AdminAPI[("Admin API v1.1.0")]
  B2BAPI --> Settlements["/settlements"]
  B2BAPI --> Financials["/reports/financials"]
  AdminAPI --> Tokens["/tokens (PAT)"]
Loading
High-Level Assessment

The chosen approach is appropriate: centralizing confirmation and export handling via small helpers removes duplicated logic and ensures consistent behavior across commands. No substantially better architectural alternative stands out for this scope.

Files changed (13) +5987 / -1737

Enhancement (4) +105 / -16
admin.tsAdd admin tokens resource and standardize confirmations +25/-8

Add admin tokens resource and standardize confirmations

• Adds 'ft admin tokens' (list/create/revoke) using admin SDK token endpoints and routes confirmable admin actions through confirmOrExit for correct abort behavior.

src/commands/admin.ts

auth.tsAdd --json to login/config and keep stdout pipeable +7/-4

Add --json to login/config and keep stdout pipeable

• Adds '--json' to 'ft login' and 'ft config', and moves the login success confirmation to stderr so 'ft login --json | jq' stays valid.

src/commands/auth.ts

reports.tsAdd reports financials + real --csv exports; fix reconciliation CSV output +53/-4

Add reports financials + real --csv exports; fix reconciliation CSV output

• Adds 'ft reports financials' (GET /reports/financials) and wires '--csv' into report exports. Introduces printExport to correctly handle text/csv string payloads (fixing #22) and to serialize JSON rows to CSV when requested.

src/commands/reports.ts

index.tsRegister settlements resource and events search flag +20/-0

Register settlements resource and events search flag

• Adds read-only 'settlements' resource (GET /settlements with filters) and enables server-side search for 'events list' via '--q' query flag.

src/index.ts

Bug fix (4) +26 / -15
api-keys.tsFix revoke confirmation to exit non-zero on abort +2/-5

Fix revoke confirmation to exit non-zero on abort

• Replaces inline confirm/return flow with confirmOrExit so revocation refusal/no-TTY produces exit code 1.

src/commands/api-keys.ts

event-dates.tsFix event-date delete confirmation to exit non-zero on abort +2/-5

Fix event-date delete confirmation to exit non-zero on abort

• Switches event-date delete confirmation to confirmOrExit for consistent abort behavior and correct exit codes.

src/commands/event-dates.ts

resource.tsFix generic delete confirmation to exit non-zero on abort +2/-5

Fix generic delete confirmation to exit non-zero on abort

• Updates the shared resource delete action to use confirmOrExit, ensuring aborts stop scripts via exit code 1.

src/commands/resource.ts

input.tsIntroduce confirmOrExit helper for destructive commands +20/-0

Introduce confirmOrExit helper for destructive commands

• Adds confirmOrExit to enforce non-zero exit on abort and to fail immediately without a TTY unless --yes is provided, fixing #24 across multiple commands.

src/lib/input.ts

Tests (2) +90 / -0
reports.test.tsAdd tests for CSV passthrough and CSV row serialization +46/-0

Add tests for CSV passthrough and CSV row serialization

• Introduces unit tests for printExport, covering verbatim text/csv output, trailing newline handling, --csv array-to-CSV conversion, and JSON fallback.

src/commands/reports.test.ts

input.test.tsAdd tests ensuring abort/no-TTY exits 1 +44/-0

Add tests ensuring abort/no-TTY exits 1

• Adds unit tests validating confirmOrExit exits 1 when no TTY is available and --yes is not provided, and that --yes bypasses confirmation.

src/lib/input.test.ts

Documentation (1) +25 / -0
warm-doors-shave.mdAdd minor-release changeset for contract sync + fixes +25/-0

Add minor-release changeset for contract sync + fixes

• Adds release notes for contract 1.5.0/admin 1.1.0 features (settlements, financials, admin tokens, event search) plus the CSV and exit-code fixes.

.changeset/warm-doors-shave.md

Other (2) +5741 / -1706
admin-openapi.jsonUpdate Admin OpenAPI spec to v1.1.0 (PAT support) +2952/-1

Update Admin OpenAPI spec to v1.1.0 (PAT support)

• Regenerates the admin contract, bumping version to 1.1.0 and documenting service-token (PAT) authentication and token endpoints.

admin-openapi.json

openapi.jsonRegenerate B2B OpenAPI spec for contract v1.5.0 +2789/-1705

Regenerate B2B OpenAPI spec for contract v1.5.0

• Updates the B2B OpenAPI contract, including new/updated endpoints used by the CLI (e.g., settlements, financial reports, event search, event dates).

openapi.json

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant